home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / telecomm / zm16src.lzh / UTIL.C < prev    next >
C/C++ Source or Header  |  1988-05-19  |  5KB  |  234 lines

  1. /*
  2.  *     Utilities Module
  3.  *
  4.  *        Jwahar Bammi
  5.  *            usenet: mandrill!bammi@{decvax,sun}.UUCP
  6.  *            csnet:  bammi@mandrill.ces.CWRU.edu
  7.  *            arpa:   bammi@mandrill.ces.CWRU.edu
  8.  *            CompuServe: 71515,155
  9.  */
  10.  
  11.  
  12. #include "config.h"
  13. #include "zmdm.h"
  14.  
  15. #ifndef Vsync             /* Atari forgot these in osbind.h */
  16. #define Vsync()    xbios(37)
  17. #endif
  18.  
  19. #define GOTO(r,c)    EscSeq('Y');Bconout(2, r+040);Bconout(2, c+040)
  20.  
  21.      /* External Variables */
  22. long     pr_time   = 0L;      /* Present time      (200 Hz) */ 
  23.  
  24. #ifndef STANDALONE
  25. #ifndef REMOTE
  26. extern int  *aline_addr; /* Ptr to base of Aline variables */
  27. extern long *ms_ptr;    /* pointer to my screen memory aligned to a 256
  28.                byte boundary */
  29.  
  30.      /* Globals */
  31. static char *hs_ptr;   /* pointer to his screen memory */
  32. static int  x_saved, y_saved;    /* Saved cursor position */
  33. #endif
  34. #endif
  35.  
  36. static long *hz_200 =  (long *)0x000004ba; /* Yes the Hitch Hikers */
  37.                        /* Guide is wrong!! */
  38.  
  39. /*
  40.  * rd_time() - read the value of the systems 200 Hz counter
  41.  * must be called in Super Mode else you get
  42.  * what you deserve - MUSHROOMS!!
  43.  */
  44. void rd_time()
  45. {
  46.     pr_time = *hz_200;
  47. }
  48.  
  49. #ifndef STANDALONE
  50. /*
  51.  * my_screen() - Start using my screen memory
  52.  * for all output.
  53.  *
  54.  */
  55. void my_screen()
  56. {
  57. #ifndef REMOTE
  58.     /* The cursor position has been saved prior to calling this routine */
  59.     x_saved = aline_addr[-14];
  60.     y_saved = aline_addr[-13];
  61.  
  62.     /* save his screen memory pointer */
  63.     hs_ptr = (char *)Logbase();
  64.     
  65.     /* switch to my display memory */
  66.     Setscreen(ms_ptr, ms_ptr, -1);
  67. #else
  68.     wr_modem("\r\n\n");
  69. #endif
  70. }
  71.  
  72.  
  73. void his_screen()
  74. {
  75. #ifndef REMOTE
  76.     /* switch to his Screen memory, wait for a Vblank, so
  77.      * that the Logical Loc == Physical Loc, then pop saved
  78.      * cursor */
  79.     Setscreen(hs_ptr, hs_ptr, -1);
  80.     Vsync();
  81.     Vsync();    /* starts happening at the last one */
  82.     GOTO(y_saved, x_saved);
  83. #else
  84.     wr_modem("\r\n\n");
  85. #endif
  86.     
  87. }
  88.  
  89. /*
  90.  * hit_key() - wait for the user to hit a key
  91.  * 
  92.  */
  93. void hit_key()
  94. {
  95. #ifndef REMOTE
  96.     Bconws("\r\n\033pHit Any Key To Continue .....\033q");
  97.     Bconin(2);
  98.     Bconws("\r\n");
  99. #else
  100.     wr_modem("\r\nHit Any Key To Continue .....");
  101.     Bconin(1);
  102.     wr_modem("\r\n");
  103. #endif
  104. }
  105. #endif /* STANDALONE */
  106.  
  107. /*
  108.  * find the size of a file given its name
  109.  */
  110. long filesize(name)
  111. register char *name;
  112. {
  113.     extern struct stat statbuf;
  114.     
  115.     if(Fsfirst(name,(int)(0x01 | 0x020)) != 0)
  116.     {
  117.         return 0L;
  118.         
  119.     }
  120.  
  121.     return statbuf.st_size;
  122. }
  123.  
  124.  
  125. /*
  126.  * Write a string to console
  127.  */
  128. Bconws(s)
  129. register char *s;
  130. {
  131.     while(*s)
  132.         Bconout(2, *s++);
  133. }
  134.  
  135. #ifndef STANDALONE
  136. #ifndef REMOTE
  137. #ifndef MANX
  138. #ifndef MWC
  139.  
  140. /* **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** */
  141. /*                                       */
  142. /*  ALCYON C dependant, this routine must return the base address of       */
  143. /*    of the linea variable block                       */
  144. /*                                       */
  145. /* **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** */
  146.  
  147. /*
  148.  * return the base address of the line A variables 
  149.  */
  150. int *aaddress()
  151. {
  152.     asm("dc.w $A000");    /* Line A trap - 0000 is init aline  */
  153.                 /* d0 and a0 now contain the address */
  154.                 /* so we can just return and the result
  155.                  * will be valid
  156.                  */
  157. }
  158.  
  159.  
  160. /*
  161.  *  Make hi rez screen bios handle 50 lines of 8x8 characters
  162.  *
  163.  * Adapted to C use from origonal asm posting
  164.  *
  165.  */
  166. hi50()
  167. {
  168.     /* Switch to 50 lines display */
  169.  
  170.     asm(".dc.w    $a000");        /* get the important pointers */
  171.  
  172.     asm("move.l  04(a1),a1");    /* a1 -> 8x8 font header */
  173.  
  174.     asm("move.l  72(a1),-$0A(a0)");    /* v_off_ad <- 8x8 offset table addr */
  175.     asm("move.l  76(a1),-$16(a0)");    /* v_fnt_ad <- 8x8 font data addr */
  176.  
  177.     asm("move.w  #008,-$2E(a0)");    /* v_cel_ht <- 8    8x8 cell height */
  178.     asm("move.w  #049,-$2A(a0)");    /* v_cel_my <- 49   maximum cell "Y" */
  179.     asm("move.w  #640,-$28(a0)"); /* v_cel_wr <- 640  offset to cell Y+1 */
  180.  
  181. }
  182.    
  183. /*
  184.  * Make hi rez screen bios handle 25 lines of 8x16 characters
  185.  *
  186.  */
  187. hi25()
  188. {
  189.     
  190.     /* Switch to 25 lines display */
  191.  
  192.  
  193.     asm(".dc.w    $a000");        /* get the important pointers */
  194.     
  195.     asm("move.l  08(a1),a1");    /* a1 -> 8x16 font header */
  196.  
  197.     asm("move.l  72(a1),-$0A(a0)");    /* v_off_ad <- 8x16 offset table addr */
  198.     asm("move.l  76(a1),-$16(a0)");    /* v_fnt_ad <- 8x16 font data addr */
  199.  
  200.     asm("move.w  #0016,-$2E(a0)");    /* v_cel_ht <- 16    8x16 cell height */
  201.     asm("move.w  #0024,-$2A(a0)");    /* v_cel_my <- 24    maximum cell "Y" */
  202.     asm("move.w  #1280,-$28(a0)");    /* v_cel_wr <- 1280  vertical byte offset */
  203. }
  204.  
  205. #else
  206.  
  207. /* **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** */
  208. /*                                       */
  209. /*     MWC  dependant, this routine must return the base address of       */
  210. /*    of the linea variable block                       */
  211. /*                                       */
  212. /* **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** **WARNING** */
  213. #include <linea.h>
  214. /*
  215.  * return the base address of the line A variables 
  216.  */
  217.  
  218. int *aaddress()
  219. {
  220.     linea0();    /* Init LineA - dumps returned values into la_init */
  221.     return (int *)(la_init.li_a0); /* Return address of Parameter Block */
  222. }
  223.  
  224.         /* Mark Williams C        */
  225.         /* See file hi5025.s       */
  226.         /* for functions hi50()    */
  227.         /* and hi25()           */
  228. #endif /* MWC */
  229. #endif /* MANX */
  230. #endif /* REMOTE */
  231. #endif /* STANDALONE */
  232.  
  233. /* -eof- */
  234.